package com.fish.finance.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fish.common.constant.QueryPage;
import com.fish.common.dao.BaseIbatisDao;
import com.fish.finance.po.Settlement;

public class SettlementDAO extends BaseIbatisDao {

	private static final Log loger = LogFactory.getLog(SettlementDAO.class);
	public SettlementDAO() {
		super();
	}

	/**
	 * 根据主键查询
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public Settlement querySettlementByPrimaryKey(Settlement settlement) {
		loger.debug("selectByPrimaryKey id is :" + settlement.getSettlementId());
		return (Settlement) this.getSqlMapClientTemplate().queryForObject("SETTLEMENT.selectByPrimaryKey", settlement);
	}

	/**
	 * 模糊查询count
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public long querySettlementCountByObject(Settlement settlement) {
		return  (Long) this.getSqlMapClientTemplate().queryForObject("SETTLEMENT.countBySettlement", settlement);
	}
	/**
	 * 模糊查询
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	@SuppressWarnings("unchecked")
	public List<Settlement> querySettlementByObject(Settlement settlement,QueryPage queryPage) {
		settlement.setBeginItem(queryPage.getBeginItem());
		settlement.setEndItem(queryPage.getPageSize());
		return (ArrayList<Settlement>) this.getSqlMapClientTemplate().queryForList("SETTLEMENT.queryBySettlement", settlement);
	}

	/**
	 * 添加
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public void addSettlement(Settlement settlement) {
		this.getSqlMapClientTemplate().insert("SETTLEMENT.insert", settlement);
	}
	
	/**
	 * 修改
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public void updateSettlement(Settlement settlement) {
		
		this.getSqlMapClientTemplate().update("SETTLEMENT.updateByPrimaryKeySelective", settlement);
	}
	
}